<template>
	<view class="receive">
		<view class="nav">
			<u-tabs :list="list1" lineColor="#FF5B1A" :activeStyle="{color: '#FF5B1A'}" @click="change"
				:scrollable="false"></u-tabs>
		</view>
		<scroll-view scroll-y="true" class="main"  @scrolltolower="lower()">
			<view class="list" v-for="(item,index) of list" :key="index">
				<view class="l">
					<view class="title">{{item.name}}</view>
					<view class="info">
						<view class="other">预约时间:</view>
						<view class="con">{{item.starttime |  date('mm-dd hh:MM')}}</view>
					</view>
					<view class="info">
						<view class="other">佣金:</view>
						<view class="con">
							<view class="moeny">{{item.price}}元</view>
						</view>
					</view>
					<view class="info">
						<view class="other">人数:</view>
						<view class="con">
							<view class="num">{{item.acceptnum}}</view>/{{item.num}}
						</view>
					</view>
					<view class="info">
						<view class="con">
							<view class="moeny" @click="cancel(item.id)">取消</view>
						</view>
					</view>
				</view>
				<view class="r">
					<view class="status" v-if="type === 0">审核中</view>
					<view class="status" v-if="type === 1">发布中</view>
					<view class="status" v-if="type === 2">已完成</view>
					<view class="status" v-if="type === -1">审核失败</view>
					<image v-if="item.images" :src="oss(item.images[0])" class="cover" mode=""></image>
					<view class="give"  v-if="type === 1 || type === 2" @click="authTo(`pages/my/city/staff?id=${item.id}`)">查看人员</view>
					<view class="give"  v-if="type === -1" @click="toast(item.note)">查看拒绝理由</view>
				</view>
			</view>
			<u-empty v-if="list.length === 0 && finish" mode="data" marginTop="100">
			</u-empty>
		</scroll-view>
		<u-modal :show="show3" :closeOnClickOverlay="true" :title="note"  @cancel="show3 = false" @confirm="show3 = false"></u-modal>
		<u-modal :show="show2"  title="确定取消吗？" @confirm="confirm2" @cancel="show2 = false" :showCancelButton="true"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show2: false,
				list1: [{
					name: '待审核',
					type: 0
				}, {
					name: '发布中',
					type: 1
				}, {
					name: '已完成',
					type: 2
				}, {
					name: '审核拒绝',
					type: -1
				}],
				page: 1,
				finish: false,
				type: 0,
				list: [],
				show3: false,
				note: '',
				id: ''
			}
		},
	
		onLoad() {
			this.getList()
		},
		methods: {
			confirm2() {
				this.show2 = false
				uni.$u.http.post('/usercity', {
					types: 'del',
					id: this.id
				}).then(res => {
					if (res.code == 1) {
						uni.$u.toast(res.msg)
						this.reload()
					}
				}).catch((res) => {
						
				})
			},
			cancel(id) {
				this.id = id
				this.show2 = true
			},
			toast(note) {
				this.note = note
				this.show3 = true
			},
			change(e) {
				console.log(e)
				this.type = e.type
				this.reload()
			},
			reload() {
				this.page = 1
				this.finish = false
				this.list = []
				this.getList()
			},
			lower() {
				this.page++
				this.getList()
			},
			getList() {
				if (this.finish) {
					return
				}
				uni.$u.http.post('/usercity', {
					page: this.page,
					type: this.type,
					types: 'list'
				}).then(res => {
					if (res.code == 1) {
						this.list = this.list.concat(res.data)
						if (res.data.length === 0) {
							this.finish = true
						}
					}
				}).catch((res) => {

				})
			}
		}
	}
</script>

<style lang="scss">
	.receive {
		height: 100vh;
		background-color: #F6F6F6;
		position: relative;
		.nav {
			display: flex;
			align-items: center;
			justify-content: center;
			flex-shrink: 0;
		}

		.main {
			position: absolute;
			left: 0;
			width: 100%;
			bottom: 0;
			top: 90rpx;
			padding-top: 20rpx;
		}

		.list {
			display: flex;
			margin: 0 20rpx 10rpx;
			padding: 20rpx;
			background-color: #fff;
			border-radius: 10rpx;
			align-items: center;
			position: relative;

			.l {
				flex: 1;

				.title {
					color: #191615;
					font-size: 36rpx;
				}

				.info {
					display: flex;
					align-items: center;
					margin-top: 10rpx;

					.other {
						color: #999999;
						font-size: 28rpx;
						margin-right: 10rpx;
					}

					.con {
						color: #575859;
						font-size: 28rpx;
						display: flex;
						align-items: center;

						.moeny {
							color: #FF5B1A;
						}

						.num {
							color: #428DFC;
						}
					}
				}
			}

			.r {
				display: flex;
				flex-direction: column;
				align-items: flex-end;

				.status {
					color: #428DFC;
					font-weight: bold;
					font-size: 30rpx;
				}

				.cover {
					width: 188rpx;
					height: 154rpx;
					margin: 10rpx 0;
				}

				.give {
					color: #999999;
					font-size: 28rpx;
				}
			}
		}
	}
</style>
